package common.jsondata.impl;

import com.alibaba.fastjson.JSON;
import common.jsondata.IResponseJSONResult;

import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.Map;

public class ResponseJSONResultImpl implements IResponseJSONResult {

    /**
     * 返回json格式的数据
     * @param response
     * @param Message
     * @return
     */
    @Override
    public String ReturnJSONResunt(HttpServletResponse response, String Message) {
        Map<String, Object> jsonResult = new HashMap<String, Object>();
        response.setContentType("text/xml;charset=UTF-8");
        response.setCharacterEncoding("UTF-8");
        jsonResult.put("msg", Message);
        return JSON.toJSONString(jsonResult);
    }

    @Override
    public void setResponseUTF8(HttpServletResponse response) {
        response.setContentType("text/xml;charset=UTF-8");
        response.setCharacterEncoding("UTF-8");
    }
}
